const tools = {
  getParamFromUrl(paramKey){
    let param = location.search.split('?')[1];
    if(param){
      let paramArr = param.split('&');
      const obj = {};
      paramArr.forEach((item)=>{
        let key = item.split('=')[0] || '',
          val= item.split('=')[1] || '';
        obj[key] = val;
      })
      if(obj[paramKey]){
        return obj[paramKey];
      }else{
        return false;
      }
    }
  },
  formatYYYYMMDD(dateStr,code){
    let date = dateStr;
    let _year = date.getFullYear(),
        _month = date.getMonth() + 1,
        _date = date.getDate();

    _month =  _month < 10 ? '0'+ _month : _month;
    let result = `${_year}${code}${_month}${code}${_date}`;
    return result;
  }
}

export {tools}
